<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script src="./js/axios.js"></script>
    <script>
        axios.post('http://localhost:3000/axios', {
            uname: 'ls',
            pwd: 456
        }).then((data) => {
            console.log(data)
            const { data: res } = data
            console.log(res)
        })

        // 请求超时
        axios.defaults.timeout = 5000

        // 配置全局域名
        axios.defaults.baseURL = 'http://localhost:3000/'
        // 设置请求头
        axios.defaults.headers['mytoken'] = '15ksksk'

        axios.get('axios-json').then((data) => {
            console.log(data.data)
        })

    </script>
</body>

</html>